/**
 * Created by xxx on 2017/3/27.
 */
//用react封装
// var currentpage = 1,totlepage = 15,i;//分页的当前页和总的页数
//表单数据：宝贝昵称、学生姓名、设备IMEI号、设备手机号、学校名称、班级名称、学籍号、性别、生日、身高、体重、
var tableData = [],schoolDataAll = [],schoolDataList = [];
//表单的最高高度、当前第几页、总页数、总行数
var otherData = {currentpage:1,totlepage:0,totlerows:0,pageLeft:0,pageRight:0,imei:'',schoolname:'',status:'',schoolid:''};
//分页组件开始
var Page = React.createClass({
    setPage: function (e) {
        setPage($(e.target).html());
        this.props.onPageClick(1);
    },
    showPage: function () {
        showPage();
    },
    render: function () {
        {
            var items = [],
                svar = this,
                otherData=this.props.otherData;
            if(otherData.totlepage == 0 ){
                items.push({num:1,checked:true})
            }else if(otherData.totlepage < 6){
                for(var i = 1;i <= otherData.totlepage ;i++) {
                    if (i == otherData.currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
            }else if(otherData.currentpage >= (otherData.totlepage-2)) {//点在左边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                for(i = otherData.totlepage-2;i <= otherData.totlepage ;i++){
                    if(i == otherData.currentpage){
                        items.push({num:i,checked:true})
                    }else{
                        items.push({num:i,checked:false})
                    }
                }
            }else if(otherData.currentpage <= 3){
                for(i = 1;i <= 3 ;i++) {
                    if (i == otherData.currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
                items.push({num:'···',checked:false});
                items.push({num:otherData.totlepage,checked:false})
            }else {//点在两边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:otherData.currentpage-1,checked:false});
                items.push({num:otherData.currentpage,checked:true});
                items.push({num:otherData.currentpage+1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:otherData.totlepage,checked:false})
            }
        }
        return (
            <div className="tableInfo-page">
                <div className="page-number">每页<span className="page-number-list" onClick={this.showPage}>{pagecount}</span>条</div>
                <div className="page-list" style={{top:pageListTop+"px"}}>
                    <ul>
                        {
                            pageList.map(function (item) {
                                return (<li onClick={svar.setPage}>{item}</li>)
                            })
                        }
                    </ul>
                </div>
                <div className="page-limit">
                    <ol className="page-limit-ol">
                        <ol className="page-limit-ol">
                            <li className="page-limit-img" name="-1" onClick={otherData.pageLeft == 0?'':svar.props.onPageClick.bind(svar,-1)}><span className={otherData.pageLeft == 0?'page-limit-left-no':'page-limit-left-yes'}/></li>
                            {
                                items.map(function (item) {
                                    return (<li onClick={isNaN(item.num)?'':svar.props.onPageClick.bind(svar,item.num)} className={item.checked == true?'page-limit-num page-limit-checked':'page-limit-num'} name={item.num}>{item.num}</li>)
                                })
                            }
                            <li className="page-limit-img" name="-2" onClick={otherData.pageRight == 0?'':svar.props.onPageClick.bind(svar,-2)} ><span className={otherData.pageRight == 0?'page-limit-right-no':'page-limit-right-yes'}/></li>
                        </ol>
                    </ol>
                </div>
            </div>
        );
    }
});//分页组件结束
//学校列表的数据
var ListDate = React.createClass({
    render: function () {
        return (
            <li className="list-data-li"  onMouseOver={this.props.onMouseOverList} onMouseOut={this.props.onMouseOutList} >
                <span className="list-number" onClick={this.props.onClickSchoolList} data-id={this.props.id} title={this.props.schoolname}>{this.props.schoolname}</span>
                <span className={"list-operation list-operation"+this.props.id}>
                    <span className="list-edit"  onClick={this.props.onClickEdit}>编辑</span>
                    <span className="list-delete" onClick={this.props.onClickDelete}>删除</span>
                </span>
            </li>
        );
    }
});
//主组件开始
var ContentBody = React.createClass({
    getInitialState:function () {
        return{
            otherData:this.props.otherData,
            tableData:this.props.tableData,
            schoolDataAll:this.props.schoolDataAll,
            schoolDataList:this.props.schoolDataList,
            addresData:[],
            importRepeatData:[],
            importType:'AS',//AS 添加学生，BC 绑定白卡,CC 批量更换考勤卡 ,UD批量解绑设备
            isReportTheLoss: false,//是否为已挂失状态
            reportTheLossData: [],//装挂失设备数据
        }
    },
    componentDidMount:function () {
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"pagenumber",'1');
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+'');
        param = getJsonDataNotEmpty(param,"status",'"2"');
        param += "}";
        if(document.referrer.indexOf("deviceInfo.html") > 0 ){
            param = 'param='+localStorage.deviceListParam;
        }else{
            $(".list-number-span").addClass(" select");//选择全部样式
            localStorage.deviceListParam = param.substring(6,param.length);
        }
        suixun.ajax(serverUrl+"/deviceManage/queryDeviceList.json",param,"get",function(data){
            tableData=[];
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    tableData[i] = {devicetype:obj.devicetype,devicetypename:obj.devicetypename,factory:obj.factory,mdtid:obj.mdtid,telephone:obj.telephone,starttime:obj.starttime,endtime:obj.endtime,paystatus:obj.paystatus,fee:obj.fee,fee2:obj.fee2};
                }
                var currentData = data.info;
                var pageRight = 0,currentpage = 1,pageleft = 0;
                if(currentData.totlepage > 1){
                    pageRight = 1;
                }
                if(document.referrer.indexOf("deviceInfo.html") > 0 ){
                    var paramObj = eval("["+localStorage.deviceListParam+"]"),currentpage = paramObj[0].pagenumber;
                    if(1 < currentpage && currentpage < currentData.totlepage){
                        pageleft = 1;
                        pageRight = 1;
                    }else if(1 == currentpage && currentData.totlepage > 1){
                        pageleft = 0;
                        pageRight = 1;
                    }else if(1 == currentpage && 1 == currentData.totlepage){
                        pageleft = 0;
                        pageRight = 0;
                    }else{
                        pageleft = 1;
                        pageRight = 0;
                    }
                }
                otherData = {currentpage:currentpage,totlepage:currentData.totlepage,totlerows:currentData.totlerows,pageLeft:pageleft,pageRight:pageRight,status:"",schoolname:"",schoolid:otherData.schoolid==undefined?'':otherData.schoolid};
                svar.setState({tableData:tableData,otherData:otherData});
            }
            $(".childrenCheckBox").attr("checked",null);
            svar.selectSchoolData();
            leftList();//改变左侧高度
            svar.selectAddress();//查询地址-回收到区域储备量
        });
        //绑定回车时间
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($(".enterEvent").is(":focus")){
                    svar.toSearchClick();
                }else if($(".queryImei").is(":focus")){
                    svar.onClickQueryImei();
                }
            }
        });
    },
    /**
     * 查询设备
     * @param page
     */
    onQueryDatas:function (page) {
        //使用ajax取出数据然后组装数据列表
        var svar = this;
        var imei = $(".queryImei").val();
        if(imei.length != 0){
            if(!/^[1-9]\d*$/.test(imei)){
                suixun.alert("输入的IMEI格式错误!");
                return;
            }
        }
        suixun.showLoding();//显示加载中
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname",'"'+otherData.schoolname+'"');
        param = getJsonDataNotEmpty(param,"status",'"'+otherData.status+'"');
        param = getJsonDataNotEmpty(param,"imei",'"'+imei+'"');
        param = getJsonDataNotEmpty(param,"pagenumber",otherData.currentpage+'');
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+'');
        param += "}";
        localStorage.deviceListParam = param.substring(6,param.length);
        suixun.ajax(serverUrl+"/deviceManage/queryDeviceList.json",param,"get",function(data){
            tableData=[];
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    tableData[i] = {devicetype:obj.devicetype,devicetypename:obj.devicetypename,factory:obj.factory,mdtid:obj.mdtid,telephone:obj.telephone,starttime:obj.starttime,endtime:obj.endtime,paystatus:obj.paystatus,fee:obj.fee,fee2:obj.fee2};
                }
                var currentData = data.info;
                var pageRight = 0;
                if(currentData.totlepage > otherData.currentpage && currentData.totlepage > 1){
                    pageRight = 1;
                }
                otherData = {currentpage:page,totlepage:currentData.totlepage,totlerows:currentData.totlepage.totlerows,pageLeft:otherData.pageLeft,pageRight:pageRight,status:otherData.status,schoolname:otherData.schoolname,schoolid:otherData.schoolid==undefined?'':otherData.schoolid};
                svar.setState({tableData:tableData,otherData:otherData});
                $(".childrenCheckBox").attr("checked",false);
                $("#parentCheckBox").attr("checked",false);
            }
            leftList();//改变左侧高度
        });
    },
    /**
     * 查询学校数据
     */
    selectSchoolData: function () {
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/querySchoolList.json?param={pagenumber:1,pagecount:10000}','',"get",function(data){
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    schoolDataList[i] = {key:i,id:obj.id,timeSettingid:obj.timeSettingid,schoolname:obj.schoolname,yijiaoid:obj.yijiaoid,address:obj.address,dis:obj.dis,showtimesetting:obj.showtimesetting};
                }
                schoolDataAll = schoolDataList;
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }else{
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }
            setTimeout(function () {
                suixun.hideLoding(500);//隐藏加载中
                var paramObj = eval("["+localStorage.deviceListParam+"]"),schoolname = paramObj[0].schoolname,selectValue = paramObj[0].status;
                if(selectValue == '3'){
                    selectValue = "已缴费";
                }else if(selectValue=='2'){
                    selectValue = "已激活";
                }else if(selectValue=='4'){
                    selectValue = "已过期";
                }else if(selectValue=='1'){
                    selectValue = "未激活";
                }else if(selectValue=='5'){
                    selectValue = "已回收";
                }
                $("#select-by-conditions").html(selectValue);//
                if(schoolname == "" || schoolname == undefined){//全部
                    $(".list-number-span").addClass(" select");//选择全部样式
                    otherData.schoolname = "";
                    svar.setState({otherData:otherData});
                }else{//学校
                    otherData.schoolname = schoolname;
                    svar.setState({otherData:otherData});
                    var dataUlChildren = $(".list-data-ul").children();
                    for(var i = 0;i < dataUlChildren.length;i++ ){
                        if(dataUlChildren[i].innerText === schoolname){
                            $(dataUlChildren[i]).addClass(" select");//选中的样式
                            break;
                        }
                    }
                }
            },500);
        });
    },
    /**
     * 分页
     * @param num
     * @returns {boolean}
     */
    onPageClick: function (num) {
        //分页-调用ajac然后把数据查询出来:获取name的值
        //计算currentpage
        suixun.showLoding();//显示加载中
        var onPageLeft = 0,onPageRight = 1;
        if(num > 0){
            otherData.currentpage = num;
        }else if(num == -1 && otherData.currentpage > 1){
            otherData.currentpage --;
        }else if(num == -2  && otherData.currentpage < otherData.totlepage){
            otherData.currentpage ++;
        }else if(num.toString()!='[object Object]'){
            return false;
        }
        //修改左右的按钮
        if((otherData.currentpage == otherData.totlepage && otherData.totlepage == 1)|| otherData.totlepage == 0){
            onPageLeft = 0;
            onPageRight = 0;
        }else if(otherData.currentpage == otherData.totlepage && otherData.totlepage > 1){
            onPageLeft = 1;
            onPageRight = 0;
        }else if(1 < otherData.currentpage && otherData.currentpage < otherData.totlepage){
            onPageLeft = 1;
            onPageRight = 1;
        }
        //判断查询条件
        var selectValue=this.refs.selectValue.innerHTML;
        if(selectValue=='已缴费'){
            selectValue=3;
        }else if(selectValue=='已激活'){
            selectValue=2;
        }else if(selectValue=='已过期'){
            selectValue=4;
        }else if(selectValue=='未激活'){
            selectValue=1;
        }else if(selectValue=='已回收'){
            selectValue=5;
        }else{
            selectValue="";
        }
        otherData.status = selectValue;
        otherData.pageLeft = onPageLeft;
        otherData.pageRight = onPageRight;
        this.setState({otherData:otherData});
        if(this.state.isReportTheLoss){
            var param = new FormData();
            param.append("pageno",otherData.currentpage);
            param.append("pagesize",pagecount);
            if($("#select-by-conditions-three").text()=='全部'){
                param.append("type",0);
            }else if($("#select-by-conditions-three").text()=='已注销'){
                param.append("type",1);
            }else if($("#select-by-conditions-three").text()=='未注销'){
                param.append("type",2);
            }else if($("#select-by-conditions-three").text()=='超过15天'){
                param.append("type",3);
            }
            if($("#select-by-conditions-four").text()=='全部'){
                param.append("devicetype",0);
            }else if($("#select-by-conditions-four").text()=='智能学生证'){
                param.append("devicetype",2);
            }else if($("#select-by-conditions-four").text()=='考勤卡'){
                param.append("devicetype",3);
            }
            console.log($("#select-by-conditions-four").text())
            console.log($("#select-by-conditions-three").text())
            this.getReportTheLossData(otherData.currentpage,param);
        }else{
            this.onQueryDatas(otherData.currentpage);//查询设备
        }
    },
    /**
     * 导出Excel
     */
    exportExcel:function () {
        //导出excel文档
        var svar = this;
        suixun.confirm_noTit("是否确定导出Excel?",function (data) {
           if(data){
               if(svar.state.isReportTheLoss){
                   setTimeout(function () {
                       svar.exportReportTheLossExcel();
                   },200);
               }else{
                   var param="param={";
                   param = getJsonDataNotEmpty(param,"schoolname",'"'+otherData.schoolname+'"');
                   param = getJsonDataNotEmpty(param,"status",otherData.status==undefined?null:otherData.status+'');
                   param += "}";
                   window.location.href = serverUrl+'/deviceManage/export_DeviceList.json?'+param;

               }
           }
        });
    },
    /**
     * 导出Excel——已挂失
     */
    exportReportTheLossExcel: function () {
        var type = 1;
        if($("#select-by-conditions-three").text() != '超过15天'){
            suixun.alert('请选择超过15天的设备');
            return;
        }
        if($("#select-by-conditions-four").text()=='全部'){
            suixun.alert('请选择设备类型');
            return;
        }else if($("#select-by-conditions-four").text()=='智能学生证'){
            type = 1;
        }else if($("#select-by-conditions-four").text()=='考勤卡'){
            type = 3;
        }
        if(this.state.reportTheLossData.length>0){
            window.location.href = serverUrl+'/deviceManage/exportlostreportdevicelist.json?type='+type;
        }else{
            suixun.alert('没有数据！')
        }


    },
    /**
     * 设备回收
     * @returns {boolean}
     */
    recyleDevices:function () {
        //设备回收
        var svar = this;
        if($(".childrenCheckBox:checked").length==0){
            suixun.alert("请选择需要回收的设备！");
            return false;
        }
        suixun.confirm_noTit("是否回收选中设备？",function (data) {
            if(data){
                suixun.showLoding();//显示加载中
                var imeis='';
                for(var i=0;i<$(".childrenCheckBox:checked").length;i++){
                    var select = $(".childrenCheckBox:checked");
                    var imei = $(select[i]).attr("data-value");
                    if(select.length==1){
                        imeis=imei;
                    }else{
                        if(i==select.length-1){
                            imeis+=imei;
                        }else{
                            imeis+=imei+'|';
                        }
                    }
                }
                var param="param={";
                param = getJsonDataNotEmpty(param,"imei",'"'+imeis+'"');
                param += "}";
                suixun.ajax(serverUrl+'/deviceManage/recycleDevice.json',param,"get",function(data){
                    suixun.hideLoding();//隐藏加载中
                    if(data.code == 500){
                        suixun.alert(data.msg);
                    }else if(data.info.resultstatus==1){
                        suixun.alert(data.info.resultinfo,function (data) {
                            if(data){
                                svar.onPageClick(otherData.currentpage);
                            }
                        });
                    }else if(data.info.resultstatus==3){
                        suixun.alert("其中失败的imei号为："+data.info.failimei);
                    }
                });
            }
        });
    },
    /**
     * 回收到储备量
     * 显示操作-投放到区域
     */
    recyleReserve: function () {
        var checkLength = $(".childrenCheckBox:checked").length;
        if(checkLength == 0){
            suixun.alert("请选择需要回收的设备！");
            return false;
        }
        $(".device-number").html(checkLength);
        $("#recyleReserveAddress").val("");
        $(".lower-right-close").hide();
        this.onClickCloseInput();
        $(".recyleReservePop").show();
    },
    /**
     * 点击左边的搜索
     */
    toSearchClick:function () {
        var querySchool = $("#querySchool").val();
        $(".queryImei").val("");//制空IMEI搜索框
        for(var i = 0;i < schoolDataAll.length;i++){//看批号数据里面有没有输入的批号
            if(schoolDataAll[i].schoolname == querySchool){
                schoolDataList.push({schoolname:schoolDataAll[i].schoolname,id:schoolDataAll[i].id});
                $(".querySchool").hide();//隐藏批号列表
                var listDataUl = $(".list-data-ul").children();//批号列表
                for(var j = 0;j<listDataUl.length;j++){
                    if($(listDataUl[j]).find(".list-number").html() == querySchool){
                        $('#left-body').animate({
                            scrollTop: i*25//
                        }, 100);
                        $(".list-data-div").siblings().removeClass(" select");
                        $(".list-number-span").removeClass(" select");//全部按钮
                        $(listDataUl[j]).addClass(" select").siblings().removeClass(" select");
                        $(".list-data-div-ul").show();
                        otherData.schoolname = querySchool;
                        otherData.schoolid = querySchool;
                        this.setState({otherData:otherData});
                        this.onQueryDatas(1);//查询左侧
                        break;
                    }
                }
                return;
            }
        }
    },
    /**
     * 改变弹出层学校输入框
     * @param e
     */
    onChangSchoolInput: function (e) {
        var val = $(e.target).val();
        if(val != ""){
            this.schoolArray(val,$(e.target).attr("data-list"));
        }else{
            $("."+$(e.target).attr("data-list")+"").hide();
        }
    },
    /**
     * 排序
     * @param val
     * @param cls
     */
    schoolArray: function (val,cls) {
        schoolDataList = [];
        for(var i = 0;i < schoolDataAll.length;i++){
            if((schoolDataAll[i].schoolname).indexOf(val) >= 0){
                schoolDataList.push({schoolname:schoolDataAll[i].schoolname,id:schoolDataAll[i].id});
            }
        }
        if(schoolDataList.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({schoolDataList:schoolDataList});
        }
    },
    /**
     * 点击学校输入框
     * @param e
     */
    onClickSchool: function (e) {
        var val = $(e.target).val();
        this.schoolArray(val,$(e.target).attr("data-list"));
    },
    /**
     * table组件
     */
    clickChecked: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        }
        if(b == childsCheckBox.length-a){
            $("#parentCheckBox").prop('checked',true);
        }else{
            $('#parentCheckBox').attr('checked',false);
        }
    },
    /**
     * table组件
     */
    clickCheckedTwo: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        };
        if(b == childsCheckBox.length-a){
            $("#parentCheckBoxTwo").prop('checked',true);
        }else{
            $('#parentCheckBoxTwo').attr('checked',false);
        }
    },
    /**
     * 查看
     * @param e
     */
    onClickSelect: function (e) {
        localStorage.deviceType = "mdtid";
        localStorage.mdtid=$(e.target).attr("data-value");
        window.location.href = serverUrl+"/deviceManage/deviceInfo.html";
    },
    //点击左侧学校操作事件
    /**
     * 左边列表编辑按钮
     * @param info
     */
    onClickEdit: function (info) {
        //组装考勤区间
        suixun.showLoding();//显示加载中
        var showtimesettings = info[5].split(" "),svar = this;
        for(var i = 0;i < showtimesettings.length;i++){
            if(showtimesettings[i] == ""){
                continue;
            }
            $(".time-father").append('' +
                '<span class="time-array">' +
                '<span class="pop-body-input-content" >' +
                ' <input size="16" style="margin-top: 0px" class="input-content inputTime timeMapFirst" type="text" placeholder="选择时间" value="'+showtimesettings[i].split("-")[0]+'"  />' +
                '</span>' +
                '<span class="pop-body-input-content timeRight" >' +
                '<input size="16" style="margin-top: 0px"  class="input-content inputTime timeMapLast" data-ids="id"  type="text" placeholder="选择时间" value="'+showtimesettings[i].split("-")[1]+'"  />' +
                '<img class="schoolDeleteTime" data-value="id" src="../img/icon/delete.png" />' +
                '</span>' +
                '</span>');

            $('.inputTime').datetimepicker({
                datepicker:false,//关闭日期选项
                format:'H:i',//格式化日期
                step:5//时间间隔
            });
        }
        //考勤区间ids
        if(info[6] != null){
            $("#timeSettingid").val(info[6]);
        }else{
            $("#timeSettingid").val("");
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname",info[2]);
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data.code == 200){
                $(".schoolPop").css("display","block");
                $("#schoolName").next().val(info[0]);//存放学校id
                $("#pop-schoolName").val(info[2]);
                $('#schoolAddress').val(info[1]);
                $('#yijiaoid').val(info[3]);
                if(data.info[0].province == null){
                    $(".span-provinceid").html("选择省份").attr("title","选择省份");
                    $(".span-cityid").html("选择地区").attr("title","选择地区");
                    $(".span-countyid").html("选择县或街道").attr("title","选择县或街道");
                    $("#provinceid").val("");
                    $("#cityid").val("");
                    $("#countyid").val("");//省市区
                }else{
                    $(".span-provinceid").html(data.info[0].province).attr("title",data.info[0].province);
                    $(".span-cityid").html(data.info[0].city).attr("title",data.info[0].city);
                    $(".span-countyid").html(data.info[0].town).attr("title",data.info[0].town);
                    $("#provinceid").val(data.info[0].province);
                    $("#cityid").val(data.info[0].city);
                    $("#countyid").val(data.info[0].town);//省市区
                }
            }else {
                suixun.alert(data.msg);
            }
        });
    },
    /**
     * 左边列表删除按钮
     * @param id
     */
    onClickDelete: function (id) {
        var svar = this;
        suixun.confirm_noTit('是否删除学校?',function (data) {
            if(data == true) {
                suixun.showLoding();//显示加载中
                var param = "param={";
                param = getJsonDataNotEmpty(param, "schoolid", "\"" +id + "\"");
                param += "}";
                suixun.ajax(serverUrl + '/schoolManage/deleteSchool.json',param,"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if (data != null && data.info != null && data.code == 200) {
                        suixun.alert("删除成功!",function (data) {
                            if(data){
                                suixun.showLoding();//显示加载中
                                svar.selectSchoolData();
                            }
                        });
                    } else {
                        suixun.alert(data.msg);
                    }
                });
            }
        });
    },
    /**
     * 点击学校名称列表
     * @param info
     */
    onClickSchoolList: function (info) {
        $("#select-by-conditions").html("已激活");
        $(".queryImei").val("");//制空IMEI搜索框
        otherData.status = "2";
        otherData.schoolname = info[0];
        otherData.schoolid = info[0];
        this.setState({otherData:otherData});
        this.onQueryDatas(1);//查询左侧
    },
    /**
     * 点击全部
     * @param e
     */
    onClickAll: function (e) {
        $("#select-by-conditions").html("已激活");
        $(".list-number-span").addClass(" select");
        $(".list-data-li").siblings().removeClass(" select");
        $(".queryImei").val("");//制空IMEI搜索框
        $("#querySchool").val("");//制空学校搜索框
        otherData.schoolname = "";
        otherData.status = "2";
        this.setState({otherData:otherData});
        this.onQueryDatas(1);//查询左侧
    },
    onMouseOverList: function (id) {
        $(".list-operation"+id+"").show();
    },
    onMouseOutList: function (id) {
        $(".list-operation"+id+"").hide();
    },
    /**
     * 学校弹出层
     */
    onClickHidePop:function () {
        $(".popPhone").css("display","none");
        $(".errorMsg").css("display","none");
        $("#province").find(".pop-address-content-default").html('选择省份');
        $("#city").find(".pop-address-content-default").html('选择地区');
        $("#county").find(".pop-address-content-default").html('选择县或街道');
        $("#pop-schoolName").val('');
        $("#yijiaoid").val('');
        $("#schoolAddress").val('');
        $('#countyid').val('');
        $(".time-father").html("");
    },
    /**
     * 保存学校
     * @type {*}
     */
    onClockSaveSchool:function () {
        var svar = this;
        var schoolName = $('#pop-schoolName').val();//学校名称
        var schoolAddress = $('#schoolAddress').val();//学校地址
        var yijiaoid = $('#yijiaoid').val();//壹教云
        var provinceid = $("#provinceid").val(),cityid = $("#cityid").val(),countyid = $("#countyid").val();//省市区
        if(schoolName == ""){
            suixun.alert("学校名称不能为空!");
            $(".schoolName-error").show();
            return;
        }
        if(schoolAddress == ""){
            suixun.alert("学校地址不能为空!");
            $(".schoolAddress-error").show();
            return;
        }
        if(yijiaoid == ""){
            suixun.alert("壹教云ID不能为空!");
            $(".yijiaoid-error").show();
            return;
        }
        if(provinceid != "" ){
            if(cityid == "" ){
                suixun.alert("选择地区");
                return;
            }else{
                if(countyid == "" ){
                    suixun.alert("选择县或街道");
                    return;
                }
            }
        }
        suixun.showLoding();//显示加载中
        var timeLen=$('.timeMapFirst').length;
        var showtimesetting='';
        for(var i=0;i<timeLen;i++){
            var startTime=$('.timeMapFirst').eq(i).val();
            var endTime=$('.timeMapLast').eq(i).val();
            var isId = $('.timeMapLast').eq(i).attr("data-ids");
            if(isId == 'id' && $('.timeMapLast').eq(i).parent().parent().is(":hidden")){
                if(i==timeLen-1){
                    showtimesetting+='';
                }else{
                    showtimesetting+=',';
                }
            }else if(startTime!=""&&endTime!=""){
                if( startTime.substring(0,2)>endTime.substring(0,2)){
                    suixun.alert('考勤区间不符');
                    return false;
                }else if(startTime.substring(0,2)==endTime.substring(0,2)&&startTime.substring(3,5)>endTime.substring(3,5)){
                    suixun.alert('考勤区间不符');
                    return false;
                }
                if(i==timeLen-1){
                    showtimesetting+=startTime+'-'+endTime;
                }else{
                    showtimesetting+=startTime+'-'+endTime+',';
                }
            }
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname", "\""+schoolName+"\"");
        param = getJsonDataNotEmpty(param,"id","\""+$('#schoolName').next().val()+"\"");
        param = getJsonDataNotEmpty(param,"address","\""+schoolAddress+"\"");
        param = getJsonDataNotEmpty(param,"yijiaoid","\""+yijiaoid+"\"");
        param = getJsonDataNotEmpty(param,"province","\""+provinceid+"\"");
        param = getJsonDataNotEmpty(param,"timeSettingid","\""+ $("#timeSettingid").val()+"\"");
        param = getJsonDataNotEmpty(param,"city","\""+cityid+"\"");
        param = getJsonDataNotEmpty(param,"town","\""+countyid+"\"");
        param = getJsonDataNotEmpty(param,"showtimesetting","\""+showtimesetting+"\"");
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/modifySchool.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data.code == 200){
                suixun.alert("修改成功!",function (data) {
                    if(data){
                        svar.onClickHidePop();
                        suixun.showLoding();//显示加载中
                        svar.selectSchoolData();
                    }
                });
            } else {
                suixun.alert(data.msg);
            }
        });
    },
    /**
     * 新增时间区间
     * @type {*}
     */
    onClickaddSchoolTime: function () {
        $(".time-father").append('' +
            '<span class="time-array">' +
            '<span class="pop-body-input-content" >' +
            ' <input size="16" style="margin-top: 0px" class="input-content inputTime timeMapFirst" type="text" placeholder="选择时间" value=""  />' +
            '</span>' +
            '<span class="pop-body-input-content timeRight" >' +
            '<input size="16" style="margin-top: 0px"  class="input-content inputTime timeMapLast" type="text" placeholder="选择时间" value=""  />' +
            '<img class="schoolDeleteTime" src="../img/icon/delete.png" />' +
            '</span>' +
            '</span>');
        $('.inputTime').datetimepicker({
            datepicker:false,//关闭日期选项
            format:'H:i',//格式化日期
            step:5//时间间隔
        });
    },
    /**
     * 验证
     * @type {*}
     */
    onBlurInput: function (e) {
        var classname = e.target.getAttribute("data-error");
        if($(e.target).val() == ''){
            $("."+classname+"").show();
        }else{
            $("."+classname+"").hide();
        }
    },
    /**
     * 点击左侧搜索框展开学校列表
     * @type {*}
     */
    onClickBachIdList: function (e) {
        var target = $(e.target);
        $("#querySchool").val(target.html());
        $(".querySchool").hide();//隐藏批号列表
        $(".queryImei").val("");//制空IMEI搜索框
        var listDataUl = $(".list-data-ul").children();//批号列表
        for(var i = 0;i<listDataUl.length;i++){
            if($(listDataUl[i]).find(".list-number").html() == target.html()){
                $('#left-body').animate({
                    scrollTop: i*25//
                }, 100);
                $(".list-number-span").removeClass(" select");//全部按钮
                $(".list-data-div").siblings().removeClass(" select");
                $(listDataUl[i]).addClass(" select").siblings().removeClass(" select");
                $(".list-data-div-ul").show();
                //设置批号编号
                otherData.schoolname = target.html();
                otherData.schoolid = target.html();
                this.setState({otherData:otherData});
                this.onQueryDatas(1);//查询左侧
                break;
            }
        }
    },
    /**
     * 更具imei号查询
     * @type {*}
     */
    onClickQueryImei: function () {
        var imei = $(".queryImei").val();
        if(imei.length != 0){
           if(!/^[1-9]\d*$/.test(imei)){
                suixun.alert("输入的IMEI格式错误!");
                return;
            }
        }
        var svar = this;
        suixun.showLoding();//显示加载中
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname",'"'+otherData.schoolname+'"');
        param = getJsonDataNotEmpty(param,"status",'"'+otherData.status+'"');
        param = getJsonDataNotEmpty(param,"imei",'"'+imei+'"');
        param = getJsonDataNotEmpty(param,"pagenumber",otherData.currentpage+'');
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+'');
        param += "}";
        localStorage.deviceListParam = param.substring(6,param.length);
        suixun.ajax(serverUrl+"/deviceManage/queryDeviceList.json",param,"get",function(data){
            tableData=[];
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    tableData[i] = {devicetype:obj.devicetype,devicetypename:obj.devicetypename,factory:obj.factory,mdtid:obj.mdtid,telephone:obj.telephone,starttime:obj.starttime,endtime:obj.endtime,paystatus:obj.paystatus,fee:obj.fee,fee2:obj.fee2};
                }
                var currentData = data.info;
                var pageRight = 0;
                if(currentData.totlepage > 1){
                    pageRight = 1;
                }
                otherData = {currentpage:1,totlepage:currentData.totlepage,totlerows:currentData.totlepage.totlerows,pageLeft:0,pageRight:pageRight,status:otherData.status,schoolname:otherData.schoolname,schoolid:otherData.schoolid==undefined?'':otherData.schoolid};
                svar.setState({tableData:tableData,otherData:otherData});
                $(".childrenCheckBox").attr("checked",null);
                leftList();//改变左侧高度
            }
        });
    },
    /**
     * addresData
     * 查询地址-省份
     */
    selectAddress:function () {
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type","1");
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            if(data.code == 200){
                let addresData=[];
                for(let i = 0 ;i < data.info.length;i++ ){
                    addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                }
                svar.setState({addresData:addresData});
            }
        });
    },
    /**
     * 清空地区并隐藏地区
     *  然后去调用分页
     * @returns {XML}
     */
    onClickCloseInput: function () {
        $("#recyleReserveAddress").val("");
        $(".addressesOne").hide();
        $(".noPopValue").hide();
        $(".province").addClass(" addresses-select cli");
        $(".city").removeClass("cli addresses-select");
        $(".area").removeClass(" cli addresses-select");
        this.selectAddress();
    },
    /**
     * 查询地址
     * @param e
     */
    queryAddress:function (e) {
        var type = $(e.target).attr("data-type"),
            province = $(e.target).attr("data-province"),
            city = $(e.target).attr("data-city");
        if(type == "1"){
            $("#recyleReserveAddress").val(province);
            $("#recyleReserveAddress").attr("title",province);
            $(".province").removeClass(" addresses-select");
            $(".province").addClass(" cli");
            $(".city").addClass(" addresses-select");
            $(".area").removeClass(" cli");
            $(".noPopValue").show();//显示关闭按钮
        }else  if(type == "2"){
            $("#recyleReserveAddress").val(province+"-"+city);
            $("#recyleReserveAddress").attr("title",province + "-" + city );
            $(".city").removeClass(" addresses-select");
            $(".city").addClass(" cli");
            $(".area").addClass(" addresses-select");
            $(".noPopValue").show();//显示关闭按钮
        }else {
            $("#recyleReserveAddress").val(province + "-" + city + "-" + e.target.innerHTML);
            $("#recyleReserveAddress").attr("title",province + "-" + city + "-" + e.target.innerHTML);
            $(".addressesOne").hide();
            $(".noPopValue").show();//显示关闭按钮
            return;
        }
        type = parseInt(type)+1;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            let addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});
        });
    },
    /**
     * 点击城市
     * @param e
     */
    onClickCity: function (e) {
        var type = $(e.target).attr("data-type"),addres = $("#recyleReserveAddress").val(),addreses = addres.split("-"),province = "",city = "";
        if(addres == "选择省市区"){
            return;
        }
        if(type == "1"){
            province = "";
            city = "";
        }else if(type == "2"){
            if(addreses[0] != ""){
                province = addreses[0];
                city = "";
            }else{
                return;
            }
        }else if(type == "3"){
            if(addreses[0] != "" && addreses.length > 1){
                province = addreses[0];
                city = addreses[1];
            }else{
                return;
            }
        }else if(type == "4"){
            $(".addressesOne").hide();
            return;
        }
        $(e.target).addClass(" addresses-select").siblings().removeClass(" addresses-select");
        if(addreses[0] != "" && addreses.length == 1){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").removeClass(" cli");
        }else if(addreses.length == 2 || addreses.length == 3){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").addClass(" cli");
        }else{
            $(".city").removeClass("cli");
            $(".area").removeClass(" cli");
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            let addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});
        });
    },
    /**
     * 点击选择地区
     * @returns {XML}
     */
    onClickAddressSelect: function () {
        if($(".addressesOne").is(":hidden")){
            $(".addressesOne").show();
        }else{
            $(".addressesOne").hide();
        }
    },
    /**
     * 点击回收设备
     */
    onClickRecyleReserve: function () {
        var address = $("#recyleReserveAddress").val();
        if(address == ""){
            suixun.alert("请选择省市区");
            return;
        }else if(address.split("-").length != 3){
            suixun.alert("请选择完整的省市区");
            return;
        }
        var imeis='',svar = this;
        for(var i=0;i<$(".childrenCheckBox:checked").length;i++){
            var select = $(".childrenCheckBox:checked");
            var imei = $(select[i]).attr("data-value");
            if(select.length==1){
                imeis=imei;
            }else{
                if(i==select.length-1){
                    imeis+=imei;
                }else{
                    imeis+=imei+'|';
                }
            }
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"imei",'"'+imeis+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+address.split("-")[0]+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+address.split("-")[1]+'"');
        param = getJsonDataNotEmpty(param,"town",'"'+address.split("-")[2]+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/deviceManage/recycleToReserve.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中

            if(data.code == 200){
                suixun.alert("回收成功！",function (data) {
                    if(data){
                        svar.onClickHidePop();
                        svar.onPageClick(otherData.currentpage);
                    }
                });
            }else{
                suixun.alert(data.msg);
            }
        });
    },
    exportTimeCard(value,type){
    	 suixun.confirm_noTit("是否下载"+value+"Excel模版？",function (data) {
             if(data){
                 //AS 添加学生，BC 绑定白卡,CC 批量更换考勤卡 ,UD 批量解绑设备
                 if(type=="BC"){
                     window.location.href = serverUrl+"/deviceManage/exportbatchbindwhitecardTemplate.json";
                 }else if(type=="AS"){
                     window.location.href = serverUrl+"/deviceManage/export_batchActivateCardTamplate.json";
                 }else if(type=="CC"){
                     window.location.href = serverUrl+"/deviceManage/changeDeviceTamplate";
                 }else if(type=="UD"){
                     window.location.href = serverUrl+"/deviceManage/unbindManyTamplate";
                 }
             }
         });
    },
    /**
     * 白卡批量导入
     */
    inportTimeCard(value){
        $(".excelInput").show();
        this.setState({importType:value});
    },
    /**
     * 白卡导入
     *  AS 添加学生，BC 绑定白卡,CC 批量更换考勤卡 ,UD 批量解绑设备
     */
    excelInput(){
        var svar = this;
        var file_name = $(".file_name").val();
        if(file_name != ""){
            suixun.showLoding();//显示加载中
            var formData=new FormData($("#excelInputFrom")[0]);
            if(svar.state.importType =='BC'){
                //智能学生证关联白卡
                suixun.ajax(serverUrl+'/deviceManage/bindwhitecardBatch.json',formData,"post",function(result){
                    suixun.hideLoding(200);//隐藏加载中
                    if(result.code == 0){
                        if(result.data != null && result.data != '' && result.data != undefined){
                            // suixun.alert('部分导入成功',function (data) {
                            //     if(data){
                            //         alert(11);
                            //
                            //     }
                            // });
                            suixun.confirm(result.data.replace(/；/g,';<br/>'),'导入失败部分',function (data) {
                                if(data){
                                    $(".excelInput").hide();
                                    svar.onPageClick(1);
                                }
                            });
                        }else{
                            suixun.alert('全部导入成功',function (data) {
                                if(data){
                                    $(".excelInput").hide();
                                    svar.onPageClick(1);
                                }
                            });
                        }
                    }else{
                        suixun.alert(result.msg);
                    }
                });
            }else if(svar.state.importType =='AS'){
                //批量添加学生
                suixun.ajax(serverUrl+'/deviceManage/batchActivateCard.json',formData,"post",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200 && data.info == null){//成功
                        suixun.alert('导入成功',function (data) {
                            if(data){
                                $(".excelInput").hide();
                                svar.onPageClick(1);
                                // svar.onClickQueryLastDev();
                                // svar.queryAllDevice();//查询所有的设备
                                //
                                // //查询批号
                                // suixun.ajax(serverUrl+'/batchManage/queryBatch.json','',"get",function(data){
                                //     if(data.code == 200){
                                //         for(var i=0;i<data.info.length;i++){
                                //             var obj=data.info[i];
                                //             listData[i] = {id:obj.id,batchid:obj.batchid};
                                //         }
                                //         svar.setState({listData:listData});
                                //     }
                                // });
                            }
                        })
                    }else{
                        suixun.alert(data.msg);
                    }
                });
            }else if(svar.state.importType =='CC'){//批量更换考勤卡
                suixun.ajax(serverUrl+'/deviceManage/changeDevice.json',formData,"post",function(result){
                    suixun.hideLoding(200);//隐藏加载中
                    if(result.code == 200){
                        suixun.alert('全部导入成功',function (data) {
                            if(data){
                                $(".excelInput").hide();
                                svar.onPageClick(1);
                            }
                        });
                    }else{
                        suixun.alert(result.msg);
                    }
                });
            }else if(svar.state.importType =='UD'){//批量解绑设备
                suixun.ajax(serverUrl+'/deviceManage/unbindManyDevice.json',formData,"post",function(result){
                    suixun.hideLoding(200);//隐藏加载中
                    if(result.code == 200){
                        suixun.alert('全部导入成功',function (data) {
                            if(data){
                                $(".excelInput").hide();
                                svar.onPageClick(1);
                            }
                        });
                    }else{
                        suixun.alert(result.msg);
                    }
                });
            }
        }else{
            suixun.alert("请选择上传文件!");
        }
    },
    /**
     * 点击下拉框设置文本内容
     */
    dropDownText: function (type,e) {
        var parentone = e.target.parentNode,svar = this;
        parentone.previousElementSibling.previousElementSibling.innerHTML = e.target.innerHTML;
        $("."+parentone.className+"").slideUp();
        if(e.target.innerHTML=='已挂失'&&type){
            suixun.showLoding();//显示加载中
            document.querySelector("#select-by-conditions-two").innerHTML = '已挂失';
            this.setState({isReportTheLoss:true});
            var param = new FormData();
            param.append("type",0);
            param.append("devicetype",0);
            param.append("pageno",1);
            param.append("pagesize",pagecount);
            this.getReportTheLossData(1,param);
            return;
        }else if(type){
            this.onPageClick(1);
        }else{
            suixun.showLoding();//显示加载中
            document.querySelector("#select-by-conditions").innerHTML = e.target.innerHTML;
            this.setState({isReportTheLoss:false});
            setTimeout(function () {
                svar.onPageClick(1);
            },300);

        }
    },
    /**
     * 获取挂失设备列表
     */
    getReportTheLossData: function (num,param) {
        var svar = this;
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+"/deviceManage/getlostreportdevice.json",param,"post",function(result){
            tableData=[];
            suixun.hideLoding();//隐藏加载中
            if(result.code == 0){
                if(result.data){
                    svar.state.otherData.currentpage = num;
                    svar.state.otherData.totlepage = result.data.pages;
                    svar.state.otherData.totlerows = result.data.pageNum;
                    svar.state.otherData.pageLeft = result.data.prePage;
                    svar.state.otherData.pageRight = result.data.nextPage;
                    if(result.data.list != null && result.data.list.length>0){
                        svar.setState({reportTheLossData:result.data.list,otherData:otherData});
                    }else{
                        svar.setState({reportTheLossData:[],otherData:otherData});
                    }
                    $(".childrenCheckBoxTwo").attr("checked",false);
                    $("#parentCheckBoxTwo").attr("checked",false);
                }else{
                    svar.setState({reportTheLossData:[]});
                    $(".childrenCheckBoxTwo").attr("checked",false);
                    $("#parentCheckBoxTwo").attr("checked",false);
                }
            }else{
                suixun.alert(result.msg);
            }
            leftList();//改变左侧高度
        });
    },
    /**
     * 注销
     */
    setReportTheLoss: function (id) {
        var svar = this;
        var param = new FormData();
        param.append("lostreportids",id);
        suixun.confirm_noTit("是否确定注销?",function (data) {
            if(data){
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+"/deviceManage/ logoffafterlost.json",param,"post",function(result){
                    suixun.hideLoding();//隐藏加载中
                    if(result.code == 0){
                        suixun.alert('操作成功！',function (data) {
                            if(data){
                                svar.onPageClick(svar.state.otherData.currentpage);
                            }
                        });
                    }else{
                        suixun.alert(result.msg);
                    }
                });
            }
        });
    },
    /**
     * 批量注销
     * @returns {boolean}
     */
    recyleReportTheLoss:function () {
        //设备回收
        var svar = this;
        if($(".childrenCheckBoxTwo:checked").length==0){
            suixun.alert("请选择需要注销的设备！");
            return false;
        }
        suixun.confirm_noTit("是否注销选中设备？",function (data) {
            if(data){
                var ids='';
                for(var i=0;i<$(".childrenCheckBoxTwo:checked").length;i++){
                    var select = $(".childrenCheckBoxTwo:checked");
                    var imei = $(select[i]).attr("data-value");
                    if(select.length==1){
                        ids=imei;
                    }else{
                        if(i==select.length-1){
                            ids+=imei;
                        }else{
                            ids+=imei+',';
                        }
                    }
                }
                console.log(ids);
                var param = new FormData();
                param.append("lostreportids",ids);
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+"/deviceManage/ logoffafterlost.json",param,"post",function(result){
                    suixun.hideLoding();//隐藏加载中
                    if(result.code == 0){
                        suixun.alert('操作成功！',function (data) {
                            if(data){
                                svar.onPageClick(svar.state.otherData.currentpage);
                            }
                        });
                    }else{
                        suixun.alert(result.msg);
                    }
                });
            }
        });
    },
    render:function(){
        {
            var svar = this;
            var onClickArray = [this.onClickEdit,this.onClickDelete,this.onClickSchoolList,this.dropDownText,this.onPageClick];
            var onMoutArray = [this.onMouseOverList,this.onMouseOutList,this.onClickBachIdList];//onClickBachIdList 是点击左侧列表
            var listDatas = schoolDataAll.map(function (data) {
                return (
                    <ListDate key={data.id} id={data.id} address={data.address} schoolname={data.schoolname} onClickSchoolList={onClickArray[2].bind(svar,[data.schoolname,data.id])} onMouseOutList={onMoutArray[1].bind(svar,data.id)} onMouseOverList={onMoutArray[0].bind(svar,data.id)} onClickDelete={onClickArray[1].bind(svar,data.id)} onClickEdit={onClickArray[0].bind(svar,[data.id,data.address,data.schoolname,data.yijiaoid,data.dis,data.showtimesetting,data.timeSettingid])} />
                )
            });
            //将本组件中的方法和属性拿给子组件调用
            var tableDatas = tableData.map(function (value,index) {
                {
                    var payStatus=value.paystatus;
                    switch (payStatus){
                        case 1:
                            payStatus="未激活";
                            break;
                        case 2:
                            payStatus="已激活";
                            break;
                        case 3:
                            payStatus="已缴费";
                            break;
                        case 4:
                            payStatus="已过期";
                            break;
                        case 5:
                            payStatus="已回收";
                            break;
                        default:
                            payStatus = payStatus;
                            break;
                    }
                }
                return(
                    <tr key={index} style={payStatus=="已过期"?{color:'red'}:null}>
                        <td style={{width: '4%'}}>
                            {payStatus=="未激活"?<input onClick={this.clickChecked} className="childrenCheckBox" data-value={value.mdtid} type="checkbox"/>:null}
                        </td>
                        <td style={{width: '5%'}}>{index+1}</td>
                        <td style={{width: '7%'}}>{value.devicetypename}</td>
                        <td style={{width: '7%'}}>{value.factory}</td>
                        <td style={{width: '11%'}}>{value.mdtid.substring(0,4)=="9999"?value.mdtid.substring(4,14):(value.mdtid.substring(0,4)=="8888"?value.mdtid.substring(4,14):value.mdtid)}</td>
                        <td style={{width: '10%'}}>{value.telephone}</td>
                        <td style={{width: '11%'}}>{value.starttime}</td>
                        <td style={{width: '11%'}}>{value.endtime}</td>
                        <td style={{width: '8%'}}>{payStatus}</td>
                        <td style={{width: '7%'}}>{value.fee}</td>
                        <td style={{width: '8%'}}>{value.fee2}</td>
                        <td style={{width: '6%'}}>{payStatus=="未激活"?"":(payStatus=="已回收"?"":<div onClick={this.onClickSelect}  data-value={value.mdtid} className="trButton">查看</div>)}</td>
                    </tr>
                );
            }.bind(this));
            /**
             * 挂失数据
             */
            var reportTheLossDatas = this.state.reportTheLossData.map(function (value,index) {
                return(
                    <tr key={index} >
                        <td style={{width: '5%'}}>
                            {value.logoffsimstatus=="-1"?null:<input onClick={this.clickCheckedTwo} className="childrenCheckBoxTwo" data-value={value.id} type="checkbox"/>}
                        </td>
                        <td style={{width: '8%'}}>{index+1}</td>
                        <td style={{width: '17%'}}>{value.mdtid}</td>
                        <td style={{width: '20%'}}>{value.devicetype==3?'考勤卡':'智能学生证'}</td>
                        <td style={{width: '15%'}}>{value.devicetype==3?'':value.field1}</td>
                        <td style={{width: '15%'}}>{new Date(parseInt(value.optime)).format('yyyy-MM-dd h:m:s')}</td>
                        <td style={{width: '10%'}}>{value.logoffsimstatus=="-1"?"已注销":"未注销"}</td>
                        <td style={{width: '10%'}}>{value.logoffsimstatus=="-1"?"":<div onClick={this.setReportTheLoss.bind(svar,value.id)} className="trButton">注销</div>}</td>
                    </tr>
                );
            }.bind(this));
        }

        return (
            <div className="tableManage-body">
                <ExcelInput excelInput={this.excelInput}/>
                <ImportRepeat importRepeatData={this.state.importRepeatData}/>

                <div id="content-left">
                    <div id="left-head">
                        <div id="left-search">
                            <div id="left-search-select">
                                <div id="school-or-address" ref="divValue">学校</div>
                                {/*<div id="school-or-address" className="selectByCondition" ref="divValue">学校</div>*/}
                            </div>
                            <div id="left-search-query">
                                <div id="left-search-query-input">
                                    <input type="text" className="queryVal enterEvent" onChange={this.onChangSchoolInput} onClick={this.onClickSchool} data-list="querySchool" id="querySchool" maxLength="50"  placeholder="请输入学校关键字" ref="inputValue"/>
                                </div>
                                <div id="left-search-query-img" onClick={this.toSearchClick}></div>
                                <div className="schoolList querySchool">
                                    {
                                        schoolDataList.map(function (data) {
                                            return (
                                                <span onClick={onMoutArray[2]} className="schoolList-value querySchool-val" data-id={data.id}>{data.schoolname}</span>
                                            )
                                        })
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="left-body" >
                        <div id="left-body-contents">
                            <div className="list-show-total">
                                <span className="list-number-span" onClick={this.onClickAll} >全部</span>
                            </div>
                            <div className="list-data">
                                <ul className="list-data-ul">
                                    {listDatas}
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="content-right">
                    <div className="select-school-name" id="showSchoolName">{otherData.schoolname}</div>
                    <div id="right-head" style={this.state.isReportTheLoss == true?{display:'block',height:'128px'}:{display:'none',height:'128px'}}>
                        <div id="right-head-left"  className="right-head-left report-the-loss">
                            <div id="right-head-left-select-two" className="right-head-left-select droup-select" style={{marginRight:"20px"}}>
                                <div id="select-by-conditions-two" className="selectByCondition" ref="selectValue">已挂失</div>
                                <span className="lower-right-corner"/>
                                <div className="drop-down" style={{top:'36px'}}>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已缴费</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已激活</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已过期</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>未激活</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已回收</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>已挂失</span>
                                </div>
                            </div>
                            <div id="right-head-left-select-three" className="right-head-left-select droup-select" style={{marginRight:"20px"}}>
                                <div id="select-by-conditions-three" className="selectByCondition" ref="selectValue">全部</div>
                                <span className="lower-right-corner"/>
                                <div className="drop-down" style={{top:'36px'}}>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>全部</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>已注销</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>未注销</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>超过15天</span>
                                </div>
                            </div>
                            <div id="right-head-left-select-four" className="right-head-left-select droup-select">
                                <div id="select-by-conditions-four" className="selectByCondition" ref="selectValue">全部</div>
                                <span className="lower-right-corner"/>
                                <div className="drop-down" style={{top:'36px'}}>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>全部</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>考勤卡</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>智能学生证</span>
                                </div>
                            </div>
                        </div>
                        <div id="right-head-right" className="right-head-right" style={{paddingTop:"63px"}}>
                            <div id="right-head-right-export" onClick={this.exportExcel}>
                                <span className="right-head-right-export-line"/>
                                <div id="right-head-right-export-text" >
                                    <img src="../img/icon/export.png"  />
                                    <span className="right-head-right-export-text-span" style={{top:"-12px"}}>导出excel</span>
                                </div>
                            </div>
                            <div className=" right-head-right-recyle report-the-loss" onClick={this.recyleReportTheLoss} >批量注销</div>
                        </div>
                    </div>
                    <div id="right-head" style={this.state.isReportTheLoss == false?{display:'block'}:{display:'none'}}>

                        <div id="right-head-left" className="right-head-left">
                            <div id="right-head-left-left" style={{display:"none"}}>
                                全部
                            </div>
                            <div id="right-head-left-select" className="right-head-left-select droup-select" >
                                <div id="select-by-conditions" className="selectByCondition" ref="selectValue">已激活</div>
                                <span className="lower-right-corner"/>
                                <div className="drop-down" style={{top:'36px'}}>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已缴费</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已激活</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已过期</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>未激活</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,false)}>已回收</span>
                                    <span className="select-value condition-name" onClick={onClickArray[3].bind(svar,true)}>已挂失</span>
                                </div>
                            </div>
                            <div className="header-right-query">
                                <div className="header-right-query-input" >
                                    <input className="queryVal queryImei" maxLength="14"  type="text" placeholder="请输入IMEI号查询"/>
                                </div>
                                <div className="header-right-query-img" onClick={this.onClickQueryImei}></div>
                            </div>
                            <div className="recyle-button">
                                <div className="recyle-reserve" onClick={this.recyleReserve}>回收到储备量</div>
                                <div className="recyle-reserve" onClick={this.recyleDevices}>回收</div>
                                {/*<div className="right-head-right-recyle" onClick={this.recyleDevices}>*/}
                                {/*<div id="right-head-right-recyle-inner">*/}
                                {/*<img src="../img/icon/recyle.png"  />*/}
                                {/*<span>回收</span>*/}
                                {/*</div>*/}
                                {/*</div>*/}
                            </div>
                        </div>

                        <div id="right-head-right" className="right-head-right">
                            {/*<div id="right-head-right-export" onClick={this.exportExcel}>*/}
                                {/*<span className="right-head-right-export-line"/>*/}
                                {/*<div id="right-head-right-export-text" >*/}
                                    {/*<img src="../img/icon/export.png"  />*/}
                                    {/*<span className="right-head-right-export-text-span" style={{top:"-12px"}}></span>*/}
                                {/*</div>*/}
                            {/*</div>*/}
                            <div className="recyle-reserve" onClick={this.exportExcel}>导出excel</div>
                        </div>
                    </div>
                    <div id="right-body">
                        <div className="tableInfo tableInfo-change">
                            <div className="studentsInfo-data tableInfo-data">
                                <div id="studentsInfo-data-table" className="studentsInfo-data-table tableInfo-data-table" >
                                    <table className="head-body head-body">
                                        <thead style={this.state.isReportTheLoss == false?{}:{display:'none'}}>
                                            <th style={{width: '4%'}}><input id="parentCheckBox" className="parentCheckBox" type="checkbox"/></th>
                                            <th style={{width: '5%'}}>序号</th>
                                            <th style={{width: '7%'}}>设备类型</th>
                                            <th style={{width: '7%'}}>生产商</th>
                                            <th style={{width: '11%'}}>设备IMEI号</th>
                                            <th style={{width: '10%'}}>设备手机号</th>
                                            <th style={{width: '11%'}}>激活日期</th>
                                            <th style={{width: '11%'}}>设备有效期</th>
                                            <th style={{width: '8%'}}>缴费状态</th>
                                            <th style={{width: '7%'}}>推广价</th>
                                            <th style={{width: '8%'}}>套餐价格</th>
                                            <th style={{width: '6%'}}>操作</th>
                                        </thead>
                                        <thead style={this.state.isReportTheLoss == true?{}:{display:'none'}}>
                                            <th style={{width: '5%'}}><input id="parentCheckBoxTwo" className="parentCheckBox" type="checkbox"/></th>
                                            <th style={{width: '8%'}}>序号</th>
                                            <th style={{width: '17%'}}>设备号</th>
                                            <th style={{width: '20%'}}>设备类型</th>
                                            <th style={{width: '15%'}}>设备手机号</th>
                                            <th style={{width: '15%'}}>挂失时间</th>
                                            <th style={{width: '10%'}}>注销状态</th>
                                            <th style={{width: '10%'}}>操作</th>
                                        </thead>
                                        <tbody className="delivery-body">
                                            {
                                                this.state.isReportTheLoss == true?
                                                    reportTheLossDatas ==""?'':reportTheLossDatas
                                                    :
                                                    tableData==""?'':tableDatas
                                            }
                                        </tbody>
                                    </table>
                                    {
                                        this.state.isReportTheLoss == true?
                                            reportTheLossDatas == ""?<div className="tableNoData">{tableNoDataCount}</div>:''
                                            :
                                            tableData == ""?<div className="tableNoData">{tableNoDataCount}</div>:''

                                    }
                                </div>
                            </div>
                            <Page otherData={this.state.otherData} onPageClick={this.onPageClick} />
                        </div>
                    </div>
                    <div className="footer-button-device" style={this.state.isReportTheLoss == false?{display:'block'}:{display:'none'}}>
                        <div className="batch-operation">
                            <div className="recyle-reserve " onClick={this.inportTimeCard.bind(this,"AS")}>批量添加学生</div>
                            <div className="recyle-reserve " onClick={this.exportTimeCard.bind(this,"批量添加学生","AS")}>下载模版</div>
                            <span>说明：批量导入没有硬件的学生，使其可以正常使用家校通功能</span>
                        </div>
                        <div className="batch-operation">
                            <div className="recyle-reserve " onClick={this.inportTimeCard.bind(this,"BC")} style={{width:'190px'}}>批量为智能学生证关联白卡</div>
                            <div className="recyle-reserve " onClick={this.exportTimeCard.bind(this,"批量为智能学生证关联白卡","BC")}>下载模版</div>
                            <span>说明：批量为没有绑定考勤的智能学生证用户绑定白卡</span>
                        </div>
                        <div className="batch-operation">
                            <div className="recyle-reserve " onClick={this.inportTimeCard.bind(this,"CC")}>批量更换考勤卡</div>
                            <div className="recyle-reserve " onClick={this.exportTimeCard.bind(this,"批量更换考勤卡","CC")}>下载模版</div>
                            <span>说明：批量为绑定错误白卡的用户修改为新的考勤卡</span>
                        </div>
                        <div className="batch-operation">
                            <div className="recyle-reserve " onClick={this.inportTimeCard.bind(this,"UD")}>批量解绑设备</div>
                            <div className="recyle-reserve " onClick={this.exportTimeCard.bind(this,"批量解绑设备","UD")}>下载模版</div>
                            <span>说明：批量为绑定了考勤白卡的用户解绑考勤卡</span>
                        </div>

                        {/*<div className="recyle-reserve" onClick={this.inportTimeCard.bind(this,"BC")} style={{width:'140px'}} title="批量为没有绑定考勤的智能学生证用户绑定白卡">智能学生证关联白卡</div>*/}
                        {/*<div className="recyle-reserve" onClick={this.inportTimeCard.bind(this,"BC")} style={{width:'120px'}} title="批量为绑定错误白卡的用户修改为新的考勤卡">批量更换考勤卡</div>*/}
                        {/*<div className="recyle-reserve" onClick={this.inportTimeCard.bind(this,"BC")} style={{width:'110px'}} title="批量为绑定了考勤白卡的用户解绑考勤卡">批量解绑设备</div>*/}
                        {/*<div className="recyle-reserve witchLong right"  onClick={this.exportTimeCard.bind(this,"批量添加学生")}>下载添加学生模板</div>*/}
                        {/*<div className="recyle-reserve witchLong right" onClick={this.exportTimeCard.bind(this,"智能学生证关联白卡")} style={{width:'170px',marginLeft:'10px'}}>下载学生证关联白卡模板</div>*/}
                    </div>
                </div>
                <div className="pop popPhone recyleReservePop popModel">
                    <div className="model"></div>
                    <div className="pop-info popPhone-info recyleReservePop-info popModel-info">
                        <div className="pop-title popModel-title">
                            <span className="pop-title-content popModel-title-content">选择回收区域</span>
                        </div>
                        <div className="pop-body popModel-body">
                            <input type="hidden" id="deviceIds"/>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">选择地区</span>
                                <span className="popModel-body-input-content" >
                                    <input className="input-content " id="recyleReserveAddress" title="" style={{width:"280px"}} onClick={this.onClickAddressSelect} readOnly="readOnly" type="text" placeholder="选择省市区"  />
                                    <span className="lower-right-close noPopValue" onClick={this.onClickCloseInput} />
                                    <div className="addresses addressesOne" >
                                        <div className="addresses-title">
                                            <ul className="city-tab">
                                                <li className="city-tab-list province addresses-select cli" onClick={this.onClickCity} data-type="1">省 份</li>
                                                <li className="city-tab-list city" onClick={this.onClickCity} data-type="2">城 市</li>
                                                <li className="city-tab-list area" onClick={this.onClickCity} data-type="3">区（县）</li>
                                            </ul>
                                        </div>
                                        <div className="addresses-content">
                                            <ul className="addresses-content-item">
                                                {
                                                    svar.state.addresData.map(function(data){
                                                        return(
                                                            <li onClick={svar.queryAddress} data-type={data.type} data-province={data.province} data-city={data.city} title={data.value} className="addresses-item-center text-sub">{data.value}</li>
                                                        )
                                                    })
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                </span>
                            </div>
                            <div className="popModel-body-text">
                                <span className="popModel-body-text-title" style={{right:'50px'}}>回收设备量</span>
                                <span className="popModel-body-text-content device-number" style={{right:'20px'}}/>
                            </div>
                        </div>
                        <div className="recyleReserve-button">
                            <span className="recyleReserve-button-yes" onClick={this.onClickRecyleReserve}>确定</span>
                            <span className="recyleReserve-button-no" onClick={this.onClickHidePop}>取消</span>
                        </div>
                    </div>
                </div>
                <div className="pop popPhone schoolPop popModel">
                    <div className="model"></div>
                    <div className="pop-info popPhone-info popModel-info">
                        <div className="pop-title popModel-title">
                                <span className="pop-title-content popModel-title-content">
                                    <span className="popModel-title-content-solid-left"/>
                                    <span id="schoolName">修改学校</span>
                                    <input type="hidden" />
                                    <span className="popModel-title-content-solid-right"/>
                                </span>
                            <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        </div>
                        <div className="pop-body popModel-body">
                            <input type="hidden" id="timeSettingid"/>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">学校名称</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content school" onChange={this.onChangSchoolInput} onClick={this.onClickSchool} data-list="popQuerySchool"  maxLength="50" id="pop-schoolName" data-error="schoolName-error" type="text" placeholder="请输入学校名称"/>
                                </span>
                                <div className="errorMsg schoolName-error" ></div>
                                <div className="schoolList popQuerySchool">
                                    {
                                        schoolDataList.map(function (data) {
                                            return (
                                                <span className="schoolList-value popQuerySchool-val">{data.schoolname}</span>
                                            )
                                        })
                                    }
                                </div>
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">学校地址</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content " id="schoolAddress"  data-error="schoolAddress-error" onBlur={this.onBlurInput} maxLength="50"  type="text" placeholder="请输入学校地址" />
                                </span>
                                <div className="errorMsg schoolAddress-error" ></div>
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">壹教云ID</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content " id="yijiaoid"  data-error="yijiaoid-error" onBlur={this.onBlurInput} maxLength="11" type="text" placeholder="请输入壹教云ID" />
                                </span>
                                <div className="errorMsg yijiaoid-error" ></div>
                            </div>
                            <Address/>
                        </div>
                        <div className="pop-body-input time">
                            <span className="pop-body-input-title" style={{backgroundImage: "url()",margin: "0 -29px 0 29px"}}>考勤区间</span>
                            <div className="time-father">
                                {
                                    /**
                                     * 初始化的时候没有考勤区域
                                     <span className="time-array">
                                     <span className="pop-body-input-content" >
                                     <input size="16" style={{marginTop: "0px"}} className="input-content inputTime timeMapFirst" type="text" onClick={this.onClickTimer} placeholder="选择时间" value=""  />
                                     </span>
                                     <span className="pop-body-input-content timeRight" >
                                     <input size="16" style={{marginTop: "0px"}} className="input-content inputTime timeMapLast" type="text" onClick={this.onClickTimer} placeholder="选择时间" value=""  />
                                     <img className="schoolDeleteTime" src="../img/icon/delete.png" />
                                     </span>
                                     </span>
                                     */
                                }
                            </div>
                        </div>
                        <div className="addTime" onClick={this.onClickaddSchoolTime}>
                            <img src="../img/icon/add-white.png" />
                            <span>
                                添加考勤区间
                            </span>
                        </div>
                        <div className="pop-button" onClick={this.onClockSaveSchool}>
                            <span className="pop-button-ok" >保存</span>
                        </div>
                    </div>
                </div>
                <footer id="copyright">
                    <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                </footer>
            </div>
        );
    }
});

/**
 * 获取行政区域组件开始
 * @type {*}
 */
var Address=React.createClass({
    getInitialState:function () {
        return{
            provinceData:[],
            cityData:[],
            countyData:[]
        };
    },
    queryAddress:function (num,province,city) {
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+num+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            if(data.code == 200){
                if(num == "1"){
                    var provinceData = [];
                    for(var i = 0 ;i < data.info.length;i++ ){
                        provinceData[i] = {value:data.info[i].province};
                    }
                    svar.setState({provinceData:provinceData});
                }else if(num == "2"){
                    var cityData = [];
                    for(var i = 0 ;i < data.info.length;i++ ){
                        cityData[i] = {value:data.info[i].city};
                    }
                    svar.setState({cityData:cityData});
                }else{
                    var countyData = [];
                    for(var i = 0 ;i < data.info.length;i++ ){
                        countyData[i] = {value:data.info[i].town};
                    }
                    svar.setState({countyData:countyData});
                }
            }
        });
    },
    //查询省份
    queryProvince:function () {
        if($("#province").find(".pop-address-content-selectData").css('display')=='none'&&this.state.provinceData.length>0){
            $("#province").find(".pop-address-content-selectData").css('display','block');
            $("#city").find(".pop-address-content-selectData").css('display','none');
            $("#county").find(".pop-address-content-selectData").css('display','none');
            return false;
        }else if(this.state.provinceData.length>0){
            $("#province").find(".pop-address-content-selectData").css('display','none');
            return false;
        }
        this.queryAddress(1,"","");
        $("#province").find(".pop-address-content-selectData").css('display','block');
    },
    queryCity:function () {
        if($("#provinceid").next().html()=='选择省份'||$("#province").find(".pop-address-content-selectData").css('display')=='block'){
            return false;
        }
        if($("#city").find(".pop-address-content-selectData").css('display')=='block'){
            $("#city").find(".pop-address-content-selectData").css('display','none');
            return false;
        }
        this.queryAddress(2,$(".span-provinceid").html(),"");
        $("#city").find(".pop-address-content-selectData").css('display','block');
        $("#county").find(".pop-address-content-selectData").css('display','none');
    },
    queryCounty:function () {
        if($("#provinceid").next().html()=='选择省份'||$("#cityid").next().html()=='选择地区'||$("#city").find(".pop-address-content-selectData").css('display')=='block'
            ||$("#province").find(".pop-address-content-selectData").css('display')=='block'){
            return false;
        }
        if($("#county").find(".pop-address-content-selectData").css('display')=='block'){
            $("#county").find(".pop-address-content-selectData").css('display','none');
            return false;
        }
        this.queryAddress(3,"",$(".span-cityid").html());
        $("#county").find(".pop-address-content-selectData").css('display','block');
    },
    render:function () {
        return(
            <div className="pop-body-input address">
                <span className="pop-body-input-title address-span" style={{backgroundImage:"url()"}}>地区</span>
                <div className="pop-address-contents">
                    <div className="pop-address-content" id="province">
                        <input type="hidden" id="provinceid"/>
                        <span className="pop-address-content-default text-sub span-provinceid" title="" onClick={this.queryProvince}>选择省份</span>
                        <AddressData type="1" resultData={this.state.provinceData}/>
                    </div>
                    <div  id="city" className="pop-address-content">
                        <input type="hidden" id="cityid"/>
                        <span className="pop-address-content-default text-sub span-cityid" title="" onClick={this.queryCity}>选择地区</span>
                        <AddressData type="2"  resultData={this.state.cityData}/>
                    </div>
                    <div id="county" className="pop-address-content">
                        <input type="hidden" id="countyid" value="" data-dataType="Number" data-require="true" data-msg="地区不能为空"/>
                        <span className="pop-address-content-default text-sub span-countyid" title="" onClick={this.queryCounty}>选择县或街道</span>
                        <AddressData type="3"  resultData={this.state.countyData}/>
                    </div>
                </div>
            </div>
        );
    }
});
/**
 * 批量导入
 * @type {*}
 */
var ExcelInput = React.createClass({
    //关闭弹出层
    onClickHidePop: function () {
        $("#inputExcelName").val("");
        $("#file").val("");
        $(".excelInput").hide();
    },
    //选择Excel文件
    onChangFile: function () {
        var fileUrl = $("#file").val().split('\\');//注split可以用字符或字符串分割
        var fileName = fileUrl[fileUrl.length-1];//这就是要取得的图片名称
        var fileLat = fileName.substring( fileName.lastIndexOf('.')+1 );//后缀名称
        if(fileLat == "xls" || fileLat == "xlsx" ){
            $(".file_name").val(fileName);
        }else{
            suixun.alert("请选择Excel文件上传!",function (data) {
                if(data){
                    $(".file_name").val("");
                }
            });
        }
    },
    render: function () {
        return (
            <div  className="pop popPhone excelInput popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info excelInput-info">
                    <div className="pop-title popModel-title ">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width:"180px "}} />
                                批量导入
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right"  style={{width:"180px "}} />
                        </span>
                        <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                    </div>

                    <div className="pop-body popModel-body">
                        <div className="popModel-body-input">
                            <span className="popModel-body-input-title" style={{width: "108px",lineHeight:"41px",backgroundPosition:"106px 0px"}}>选择Excel文件</span>
                            <form name="excelInputForm" id="excelInputFrom"  enctype="multipart/form-data" method="post">
                                <input className="file_name input-content export-imei" id="inputExcelName" type="text" name="filename" readOnly="readOnly"/>
                                <a href="javascript:;" className="file">选择文件
                                    <input type="file" onChange={this.onChangFile}  name="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel " id="file" />
                                </a>
                            </form>
                        </div>


                    </div>
                    <div className="popModel-button" style={{marginTop:"20px"}}>
                        <span className="popModel-button-ok" onClick={this.props.excelInput}>导入</span>
                    </div>
                </div>
            </div>
        );
    }
});
/**
 * 查看导入数据重复弹出层弹出层
 * @type {*}
 */
var ImportRepeat = React.createClass({
    onClickHidePop: function () {
        $(".popPhone").hide();
    },
    render: function () {
        {
            var importRepeatDatas = "";
                /**
                 * 白卡
                 */
                importRepeatDatas = this.props.importRepeatData.map(function (data,index) {
                    return (
                        <tr style={{height: "36px"}}>
                            <td style={{width: '10%'}}>{parseInt(index)+1}</td>
                            <td style={{width: '30%'}}>{data.mdtid}</td>
                            <td style={{width: '30%'}}>{data.batchid}</td>
                            <td style={{width: '30%'}}>{data.boxid}</td>
                        </tr>
                    )
                }.bind(this));
        }
        return (
            <div className="pop popPhone popModel popImportRepeat ">
                <div className="model"></div>
                <div className="pop-info popModel-info popPhone-info">
                    <div className="pop-title popPhone-title">
                        <span className="pop-title-content popPhone-title-content">
                            <span className="pop-title-content-solid-left popPhone-title-content-solid-left"/>
                                白卡导入重复数据
                            <span className="pop-title-content-solid-right popPhone-title-content-solid-right"/>
                        </span>
                        <span className="pop-title-img popPhone-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        <input type="hidden" name="batch_id" id="batch_id"/>
                    </div>
                    <div className="pop-body ">
                        <div className="tableInfo importRepeatTableInfo">
                            <div className="studentsInfo-data tableInfo-data">
                                <div className="studentsInfo-data-table tableInfo-data-table" >
                                    <table className="head-body ">
                                        <thead>
                                            <th style={{width: '20%',height: "10px"}}>序号</th>
                                            <th style={{width: '30%',height: "30px"}}>设备IMEI号</th>
                                            <th style={{width: '30%',height: "30px"}}>批号</th>
                                            <th style={{width: '30%',height: "30px"}}>箱号</th>
                                        </thead>
                                        <tbody >
                                            {importRepeatDatas}
                                        </tbody>
                                    </table>
                                    {importRepeatDatas==""?<div className="tableNoData">{importRepeatDatas}</div>:''}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div className="messagePrompt" >注：以上为此次导入重复数据，其他数据已导入成功!</div>
                </div>
            </div>
        );
    }
});
/**
 * 省市区组装下拉列表
 * @type {*}
 */
var AddressData = React.createClass({
    componentDidMount:function () {
        $('.pop-address-content').hover(function () {
        },function () {
            $('.pop-address-content-selectData').css('display','none');
        });
    },
    handleClick:function (e) {
        if($(e.target).attr("data-type")=="1"){
            $("#city").find(".pop-address-content-default").html('选择地区');
            $("#county").find(".pop-address-content-default").html('选择县或街道');
            this.setState({cityData:[],countyData:[]});
        }else if($(e.target).attr("data-type")=="2"){
            this.setState({countyData:[]});
            $("#county").find(".pop-address-content-default").html('选择县或街道');
        }
        $(e.target).parent().prev().html(e.target.innerHTML);
        $($(e.target).parent().prev()).attr("title",e.target.innerHTML);
        $(e.target).parent().prev().prev().val(e.target.innerHTML);
        $($(e.target).parent()).hide();
    },
    render:function () {
        var svar = this;
        var resultDATA=this.props.resultData.map(function (value,index) {
            return(
                <span onClick={svar.handleClick} data-type={svar.props.type} >{value.value}</span>
            );
        });
        return(
            <div className="pop-address-content-selectData">
                {resultDATA}
            </div>
        );
    }
});
ReactDOM.render(<ContentBody tableData={tableData} otherData={otherData} schoolDataAll={schoolDataAll} schoolDataList={schoolDataList} />,document.getElementById('tableManage'));

$(window).resize(function () {
    leftList();
});
$(function () {
    setTimeout(function () {
        leftList();
    },500);
    setTimeout(function () {
        leftList();
    },2000);
});
function leftList(){
    console.log($("#studentsInfo-data-table").height());
    // if($("#studentsInfo-data-table").height()+77 > $(window).height()){
        $("#left-body").css("height",$("#studentsInfo-data-table").height()+273+"px");
    // }else{
    //     $("#left-body").css("height",$(window).height()+131+"px");
    // }
}
//点击下拉框
$("#right-head-left-select, #right-head-left-select-two, #right-head-left-select-three, #right-head-left-select-four").click(function (e) {
    $(".drop-down").slideUp();
    if($(this).find(".drop-down").is(":hidden")){
        $(this).find(".drop-down").slideDown();
    }else{
        $(this).find(".drop-down").slideUp();
    }
});
//点击下拉列表-左侧列表
// $('#dropDown>span').click(function() {
//     $(".queryVal").attr("placeholder","请输入"+$(this).html()+"关键字");
//     $("#school-or-address").html($(this).html());
//     $('.drop-down').slideUp();
// });

//选择查询设备的条件
// $('.condition-name').click(function (e) {
//     $(this).parent().parent().find(".selectByCondition").html($(this).html());
//     $(this).parent().slideUp();
// });

//多选
$("#parentCheckBox").click(function(){
    if($(this).is(":checked")){
        $(".childrenCheckBox").prop("checked",true);
    }else{
        $(".childrenCheckBox").attr("checked",false);
    }
});
$("#parentCheckBoxTwo").click(function(){
    if($(this).is(":checked")){
        $(".childrenCheckBoxTwo").prop("checked",true);
    }else{
        $(".childrenCheckBoxTwo").attr("checked",false);
    }
});
$('.inputTime').datetimepicker({
    datepicker:false,//关闭日期选项
    format:'H:i',//格式化日期
    step:5//时间间隔
});
//删除时间区间
$(".time-father").on('click','.schoolDeleteTime',function () {
    var value = $(this).attr("data-value");
    if(value == 'id'){
        $(this).prev().val("");
        $(this).parent().prev().children().val("");
        $(this).parent().parent().hide();
    }else{
        $(this).parent().parent().remove();
    }
})
//学校下拉列表
$("*").bind("click",function(e){
    var target = $(e.target);
    if(target.closest(".popQuerySchool-val").length == 1){
        $(".popQuerySchool").hide();
        $("#pop-schoolName").val(target.html());
    }else{
        $(".schoolList").hide();
    }
    if(target.closest(".querySchool-val").length == 1){

    }else{
        $(".schoolList").hide();
    }
    if(target.closest(".city-tab-list").length == 1 || target.closest(".addresses-item-center").length == 1 || target.closest(".addresses-content").length == 1 ){

    }else{
        $(".addressesOne").hide();
    }
});
//点击学校名称
$(".list-data-ul").on("click",".list-number",function () {
    $($(this).parent()).addClass(" select").siblings().removeClass(" select");
    $(".list-number-span").removeClass(" select");
});